﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using MapWindow.Drawing;
using MapWindow.Map;
using System.Collections;
using MapWindow.Data;
using MapWindow.Components;
using SkiingTools;

namespace SkiPathFinder
{
    public class MainForm : Form
    {
        #region Constructor

        public MainForm()
        {
            InitializeComponent();

            //initialize the 'draw path' map function
            _drawPathFunction = new DrawPathFunction(mainMap);
            mainMap.MapFunctions.Add("DrawPath", _drawPathFunction);

            _drawPathFunction.PathDrawingComplete += new EventHandler<SkiPathEventArgs>(DrawPathFunction_PathDrawingComplete);
        }

        

        #endregion

        #region Private Variables
        
        private MenuStrip menuStrip1;
        private ToolStripMenuItem fileToolStripMenuItem;
        private ToolStripMenuItem openNewSkiAreaToolStripMenuItem;
        private ToolStripMenuItem createToolStripMenuItem;
        private ToolStripMenuItem saveSkiAreaToolStripMenuItem;
        private ToolStripMenuItem saveSkiAreaAsToolStripMenuItem;
        private ToolStripMenuItem settingsToolStripMenuItem;
        private ToolStripMenuItem skiPathDifficultyToolStripMenuItem;
        private ToolStripMenuItem distanceUnitsToolStripMenuItem;
        private ToolStripMenuItem elevationUnitsToolStripMenuItem;
        private ToolStripMenuItem skiPathToolStripMenuItem;
        private ToolStripMenuItem drawSkiPathToolStripMenuItem;
        private ToolStripMenuItem showGraphToolStripMenuItem;
        private ToolStripMenuItem showPathDifficultyToolStripMenuItem;
        private ToolStripMenuItem compareSkiPathsToolStripMenuItem;
        private ToolStripMenuItem helpToolStripMenuItem;
        private ToolStripMenuItem helpToolStripMenuItem1;
        private ToolStripMenuItem aboutSkiPathFinderToolStripMenuItem;
        private ToolStripMenuItem exitToolStripMenuItem;
        private ToolStripContainer toolStripContainer1;
        private StatusStrip statusStrip1;
        private ToolStripStatusLabel toolStripStatusLabel1;
        private ToolStripStatusLabel toolStripStatusLabel2;
        private ToolStripSplitButton toolStripSplitButton1;
        private SplitContainer splitContainer1;
        private MapWindow.Components.Legend legend1;
        private MapWindow.Components.mwToolStrip mwToolStrip1;
        private MapWindow.Map.Map mainMap;
        private ToolStripButton btnDrawPath;
        private ToolStripButton btnGraph;
        private ToolStripButton btnDifficulty;
        private MapWindow.Components.ApplicationManager applicationManager1;

        //this is a 'Map Function' which we use for ski path drawing
        private DrawPathFunction _drawPathFunction;
        private IRaster _demGrid;

        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        #endregion   

        #region Methods

        /// <summary>
        /// Displays the grid and all ski paths from the
        /// ski area in the map
        /// </summary>
        /// <param name="skiAreaFolder">The ski area folder</param>
        public void LoadData(string skiAreaFolder)
        {
            this.Cursor = Cursors.WaitCursor;
            
            string[] gridFiles = Directory.GetFiles(skiAreaFolder, "*.bgd");
            if (gridFiles.Length > 0)
            {
                mainMap.Layers.Clear();

                IMapRasterLayer demLayer = mainMap.AddLayer(gridFiles[0]) as IMapRasterLayer;
                _demGrid = demLayer.DataSet as IRaster;
                demLayer.LegendText = "Elevation";
                mainMap.Invalidate();
                this.Text = "SkiPathFinder - " + GetSkiAreaName(skiAreaFolder);
                mainMap.MapFrame.LegendText = GetSkiAreaName(skiAreaFolder);
            }
            else
            {
                MessageBox.Show("Error! Some of the ski area data is missing.");
            }

            //add the ski paths
            string[] skiPathFiles = Directory.GetFiles(skiAreaFolder, "*.shp");

            foreach (string pathFile in skiPathFiles)
            {
                FeatureSet sf = new FeatureSet();
                sf.Open(pathFile);

                MapLineLayer pathLay = mainMap.Layers.Add(sf) as MapLineLayer;

                if (pathLay != null)
                {
                    pathLay.LegendText = Path.GetFileNameWithoutExtension(pathFile);
                    pathLay.Symbolizer.SetWidth(2.0);
                }
            }

            mainMap.Invalidate(); //this is necessary to redraw the map
            mainMap.MapFrame.ResetBuffer();

            this.Cursor = Cursors.Default;
        }

        private void openNewSkiAreaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpeningForm frmOpen = new OpeningForm();
            frmOpen.SecondOpen = true;
            if (frmOpen.ShowDialog() == DialogResult.OK)
            {
                LoadData(Globals.SelectedAreaFolder);
            }
        }

        private string GetSkiAreaName(string skiAreaFolder)
        {
            return skiAreaFolder.Substring(skiAreaFolder.LastIndexOf(Path.DirectorySeparatorChar) + 1);
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //TODO: remind user to save paths
            Application.Exit();
        }

        /// <summary>
        /// When the 'DrawPath' button is clicked and checked
        /// </summary>
        private void btnDrawPath_Click(object sender, EventArgs e)
        {
            if (btnDrawPath.Checked == false)
            {
                btnDrawPath.Checked = true;
                mainMap.Cursor = Cursors.Cross;
                UncheckOtherButtonsButMe(btnDrawPath);
                foreach (MapFunction function in mainMap.MapFunctions.Values)
                {
                    function.Deactivate();
                }

                _drawPathFunction.Activate();
            }
            else
            {
                btnDrawPath.Checked = false;
                _drawPathFunction.Deactivate();
            }
        }

        /// <summary>
        /// Unchecks all toolstrip buttons except the current button
        /// </summary>
        /// <param name="checkedButton">The toolstrip button which should
        /// stay checked</param>
        void UncheckOtherButtonsButMe(ToolStripButton checkedButton)
        {
            foreach (ToolStripItem item in mwToolStrip1.Items)
            {
                ToolStripButton buttonItem = item as ToolStripButton;
                if (buttonItem != null)
                {
                    if (buttonItem.Name != checkedButton.Name)
                    {
                        buttonItem.Checked = false;
                    }
                }
            }
        }

        /// <summary>
        /// This Event occurs when the ski path drawing is complete
        /// </summary>
        void DrawPathFunction_PathDrawingComplete(object sender, SkiPathEventArgs e)
        {
            _drawPathFunction.Deactivate();
            
            mainMap.FunctionMode = FunctionModes.None;
            mainMap.Cursor = Cursors.Arrow;
            btnDrawPath.Checked = false;
            mainMap.MapFrame.ResetBuffer();

            //After the path is drawn and saved to shapefile, two additional steps
            //are required:
            //(1) Extract the elevation profile -- save results to [pathName]-profile.csv
            IFeatureSet shapefile = e.Shapefile;
            DataTable profileTable = ElevationProfileTool.CalculateElevationProfile(shapefile, _demGrid);
            string csvFileName = shapefile.Filename.Replace(".shp", "-profile.csv");
            ElevationProfileTool.DataTable2CSV(profileTable, csvFileName, ",");

            //(2) Analyze path difficulty -- save results to [pathName]-difficulty.csv

            //Show the graph of the path
            ShowGraph(profileTable, Path.GetFileNameWithoutExtension(shapefile.Filename));
        }

        /// <summary>
        /// Shows the graph of the ski path. The graph also includes 
        /// difficulty information and other path details.
        /// </summary>
        private void ShowGraph()
        {
            GraphForm frmGraph = new GraphForm();
            frmGraph.Show();
        }

        private void ShowGraph(DataTable profileTable, string pathName)
        {
            GraphForm frmGraph = new GraphForm();
            frmGraph.SelectedPathName = pathName;
            frmGraph.Show();
        }

        #endregion

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.openNewSkiAreaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.createToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.saveSkiAreaToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.saveSkiAreaAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.skiPathDifficultyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.distanceUnitsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.elevationUnitsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.skiPathToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.drawSkiPathToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.showGraphToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.showPathDifficultyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.compareSkiPathsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.helpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
            this.aboutSkiPathFinderToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer();
            this.statusStrip1 = new System.Windows.Forms.StatusStrip();
            this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
            this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel();
            this.toolStripSplitButton1 = new System.Windows.Forms.ToolStripSplitButton();
            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
            this.legend1 = new MapWindow.Components.Legend();
            this.mainMap = new MapWindow.Map.Map();
            this.mwToolStrip1 = new MapWindow.Components.mwToolStrip();
            this.btnDrawPath = new System.Windows.Forms.ToolStripButton();
            this.btnGraph = new System.Windows.Forms.ToolStripButton();
            this.btnDifficulty = new System.Windows.Forms.ToolStripButton();
            this.applicationManager1 = new MapWindow.Components.ApplicationManager();
            this.menuStrip1.SuspendLayout();
            this.toolStripContainer1.BottomToolStripPanel.SuspendLayout();
            this.toolStripContainer1.ContentPanel.SuspendLayout();
            this.toolStripContainer1.TopToolStripPanel.SuspendLayout();
            this.toolStripContainer1.SuspendLayout();
            this.statusStrip1.SuspendLayout();
            this.splitContainer1.Panel1.SuspendLayout();
            this.splitContainer1.Panel2.SuspendLayout();
            this.splitContainer1.SuspendLayout();
            this.mwToolStrip1.SuspendLayout();
            this.SuspendLayout();
            // 
            // menuStrip1
            // 
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.fileToolStripMenuItem,
            this.settingsToolStripMenuItem,
            this.skiPathToolStripMenuItem,
            this.helpToolStripMenuItem});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(921, 24);
            this.menuStrip1.TabIndex = 0;
            this.menuStrip1.Text = "menuStrip1";
            // 
            // fileToolStripMenuItem
            // 
            this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.openNewSkiAreaToolStripMenuItem,
            this.createToolStripMenuItem,
            this.saveSkiAreaToolStripMenuItem,
            this.saveSkiAreaAsToolStripMenuItem,
            this.exitToolStripMenuItem});
            this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
            this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
            this.fileToolStripMenuItem.Text = "File";
            // 
            // openNewSkiAreaToolStripMenuItem
            // 
            this.openNewSkiAreaToolStripMenuItem.Name = "openNewSkiAreaToolStripMenuItem";
            this.openNewSkiAreaToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
            this.openNewSkiAreaToolStripMenuItem.Text = "Open Ski Area";
            this.openNewSkiAreaToolStripMenuItem.Click += new System.EventHandler(this.openNewSkiAreaToolStripMenuItem_Click);
            // 
            // createToolStripMenuItem
            // 
            this.createToolStripMenuItem.Name = "createToolStripMenuItem";
            this.createToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
            this.createToolStripMenuItem.Text = "Create New Ski Area";
            // 
            // saveSkiAreaToolStripMenuItem
            // 
            this.saveSkiAreaToolStripMenuItem.Name = "saveSkiAreaToolStripMenuItem";
            this.saveSkiAreaToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
            this.saveSkiAreaToolStripMenuItem.Text = "Save Ski Area";
            // 
            // saveSkiAreaAsToolStripMenuItem
            // 
            this.saveSkiAreaAsToolStripMenuItem.Name = "saveSkiAreaAsToolStripMenuItem";
            this.saveSkiAreaAsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
            this.saveSkiAreaAsToolStripMenuItem.Text = "Save Ski Area As..";
            // 
            // exitToolStripMenuItem
            // 
            this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
            this.exitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
            this.exitToolStripMenuItem.Text = "Exit";
            this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
            // 
            // settingsToolStripMenuItem
            // 
            this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.skiPathDifficultyToolStripMenuItem,
            this.distanceUnitsToolStripMenuItem,
            this.elevationUnitsToolStripMenuItem});
            this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
            this.settingsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
            this.settingsToolStripMenuItem.Text = "Settings";
            // 
            // skiPathDifficultyToolStripMenuItem
            // 
            this.skiPathDifficultyToolStripMenuItem.Name = "skiPathDifficultyToolStripMenuItem";
            this.skiPathDifficultyToolStripMenuItem.Size = new System.Drawing.Size(167, 22);
            this.skiPathDifficultyToolStripMenuItem.Text = "Ski Path Difficulty";
            // 
            // distanceUnitsToolStripMenuItem
            // 
            this.distanceUnitsToolStripMenuItem.Name = "distanceUnitsToolStripMenuItem";
            this.distanceUnitsToolStripMenuItem.Size = new System.Drawing.Size(167, 22);
            this.distanceUnitsToolStripMenuItem.Text = "Distance Units";
            // 
            // elevationUnitsToolStripMenuItem
            // 
            this.elevationUnitsToolStripMenuItem.Name = "elevationUnitsToolStripMenuItem";
            this.elevationUnitsToolStripMenuItem.Size = new System.Drawing.Size(167, 22);
            this.elevationUnitsToolStripMenuItem.Text = "Elevation Units";
            // 
            // skiPathToolStripMenuItem
            // 
            this.skiPathToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.drawSkiPathToolStripMenuItem,
            this.showGraphToolStripMenuItem,
            this.showPathDifficultyToolStripMenuItem,
            this.compareSkiPathsToolStripMenuItem});
            this.skiPathToolStripMenuItem.Name = "skiPathToolStripMenuItem";
            this.skiPathToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
            this.skiPathToolStripMenuItem.Text = "Ski Path";
            // 
            // drawSkiPathToolStripMenuItem
            // 
            this.drawSkiPathToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("drawSkiPathToolStripMenuItem.Image")));
            this.drawSkiPathToolStripMenuItem.Name = "drawSkiPathToolStripMenuItem";
            this.drawSkiPathToolStripMenuItem.Size = new System.Drawing.Size(181, 22);
            this.drawSkiPathToolStripMenuItem.Text = "Draw Ski Path";
            this.drawSkiPathToolStripMenuItem.Click += new System.EventHandler(this.btnDrawPath_Click);
            // 
            // showGraphToolStripMenuItem
            // 
            this.showGraphToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("showGraphToolStripMenuItem.Image")));
            this.showGraphToolStripMenuItem.Name = "showGraphToolStripMenuItem";
            this.showGraphToolStripMenuItem.Size = new System.Drawing.Size(181, 22);
            this.showGraphToolStripMenuItem.Text = "Show Graph";
            this.showGraphToolStripMenuItem.Click += new System.EventHandler(this.showGraphToolStripMenuItem_Click);
            // 
            // showPathDifficultyToolStripMenuItem
            // 
            this.showPathDifficultyToolStripMenuItem.Name = "showPathDifficultyToolStripMenuItem";
            this.showPathDifficultyToolStripMenuItem.Size = new System.Drawing.Size(181, 22);
            this.showPathDifficultyToolStripMenuItem.Text = "Show Path Difficulty";
            this.showPathDifficultyToolStripMenuItem.Click += new System.EventHandler(this.showPathDifficultyToolStripMenuItem_Click);
            // 
            // compareSkiPathsToolStripMenuItem
            // 
            this.compareSkiPathsToolStripMenuItem.Name = "compareSkiPathsToolStripMenuItem";
            this.compareSkiPathsToolStripMenuItem.Size = new System.Drawing.Size(181, 22);
            this.compareSkiPathsToolStripMenuItem.Text = "Compare Ski Paths";
            // 
            // helpToolStripMenuItem
            // 
            this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.helpToolStripMenuItem1,
            this.aboutSkiPathFinderToolStripMenuItem});
            this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
            this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
            this.helpToolStripMenuItem.Text = "Help";
            // 
            // helpToolStripMenuItem1
            // 
            this.helpToolStripMenuItem1.Name = "helpToolStripMenuItem1";
            this.helpToolStripMenuItem1.Size = new System.Drawing.Size(182, 22);
            this.helpToolStripMenuItem1.Text = "Help";
            // 
            // aboutSkiPathFinderToolStripMenuItem
            // 
            this.aboutSkiPathFinderToolStripMenuItem.Name = "aboutSkiPathFinderToolStripMenuItem";
            this.aboutSkiPathFinderToolStripMenuItem.Size = new System.Drawing.Size(182, 22);
            this.aboutSkiPathFinderToolStripMenuItem.Text = "About SkiPathFinder";
            // 
            // toolStripContainer1
            // 
            // 
            // toolStripContainer1.BottomToolStripPanel
            // 
            this.toolStripContainer1.BottomToolStripPanel.Controls.Add(this.statusStrip1);
            // 
            // toolStripContainer1.ContentPanel
            // 
            this.toolStripContainer1.ContentPanel.Controls.Add(this.splitContainer1);
            this.toolStripContainer1.ContentPanel.Size = new System.Drawing.Size(921, 506);
            this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.toolStripContainer1.Location = new System.Drawing.Point(0, 24);
            this.toolStripContainer1.Name = "toolStripContainer1";
            this.toolStripContainer1.Size = new System.Drawing.Size(921, 553);
            this.toolStripContainer1.TabIndex = 1;
            this.toolStripContainer1.Text = "toolStripContainer1";
            // 
            // toolStripContainer1.TopToolStripPanel
            // 
            this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.mwToolStrip1);
            // 
            // statusStrip1
            // 
            this.statusStrip1.Dock = System.Windows.Forms.DockStyle.None;
            this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripStatusLabel1,
            this.toolStripStatusLabel2,
            this.toolStripSplitButton1});
            this.statusStrip1.Location = new System.Drawing.Point(0, 0);
            this.statusStrip1.Name = "statusStrip1";
            this.statusStrip1.Size = new System.Drawing.Size(921, 22);
            this.statusStrip1.TabIndex = 0;
            // 
            // toolStripStatusLabel1
            // 
            this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
            this.toolStripStatusLabel1.Size = new System.Drawing.Size(118, 17);
            this.toolStripStatusLabel1.Text = "toolStripStatusLabel1";
            // 
            // toolStripStatusLabel2
            // 
            this.toolStripStatusLabel2.Name = "toolStripStatusLabel2";
            this.toolStripStatusLabel2.Size = new System.Drawing.Size(118, 17);
            this.toolStripStatusLabel2.Text = "toolStripStatusLabel2";
            // 
            // toolStripSplitButton1
            // 
            this.toolStripSplitButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripSplitButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripSplitButton1.Image")));
            this.toolStripSplitButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripSplitButton1.Name = "toolStripSplitButton1";
            this.toolStripSplitButton1.Size = new System.Drawing.Size(32, 20);
            this.toolStripSplitButton1.Text = "toolStripSplitButton1";
            // 
            // splitContainer1
            // 
            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.splitContainer1.Location = new System.Drawing.Point(0, 0);
            this.splitContainer1.Name = "splitContainer1";
            // 
            // splitContainer1.Panel1
            // 
            this.splitContainer1.Panel1.Controls.Add(this.legend1);
            // 
            // splitContainer1.Panel2
            // 
            this.splitContainer1.Panel2.Controls.Add(this.mainMap);
            this.splitContainer1.Size = new System.Drawing.Size(921, 506);
            this.splitContainer1.SplitterDistance = 307;
            this.splitContainer1.TabIndex = 0;
            // 
            // legend1
            // 
            this.legend1.BackColor = System.Drawing.Color.White;
            this.legend1.ControlRectangle = new System.Drawing.Rectangle(0, 0, 307, 506);
            this.legend1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.legend1.DocumentRectangle = new System.Drawing.Rectangle(0, 0, 187, 428);
            this.legend1.HorizontalScrollEnabled = true;
            this.legend1.Indentation = 30;
            this.legend1.IsInitialized = false;
            this.legend1.Location = new System.Drawing.Point(0, 0);
            this.legend1.Name = "legend1";
            this.legend1.ProgressHandler = null;
            this.legend1.ResetOnResize = false;
            this.legend1.SelectionFontColor = System.Drawing.Color.Black;
            this.legend1.SelectionHighlight = System.Drawing.Color.FromArgb(((int)(((byte)(215)))), ((int)(((byte)(238)))), ((int)(((byte)(252)))));
            this.legend1.Size = new System.Drawing.Size(307, 506);
            this.legend1.TabIndex = 0;
            this.legend1.Text = "legend1";
            this.legend1.VerticalScrollEnabled = true;
            // 
            // mainMap
            // 
            this.mainMap.AllowDrop = true;
            this.mainMap.BackColor = System.Drawing.Color.White;
            this.mainMap.CollectAfterDraw = false;
            this.mainMap.CollisionDetection = true;
            this.mainMap.Cursor = System.Windows.Forms.Cursors.Arrow;
            this.mainMap.CursorMode = MapWindow.Components.FunctionModes.None;
            this.mainMap.Dock = System.Windows.Forms.DockStyle.Fill;
            this.mainMap.ExtendBuffer = false;
            this.mainMap.FunctionMode = MapWindow.Components.FunctionModes.None;
            this.mainMap.Legend = this.legend1;
            this.mainMap.Location = new System.Drawing.Point(0, 0);
            this.mainMap.Name = "mainMap";
            this.mainMap.ProgressHandler = null;
            this.mainMap.SelectionEnabled = true;
            this.mainMap.Size = new System.Drawing.Size(610, 506);
            this.mainMap.TabIndex = 0;
            // 
            // mwToolStrip1
            // 
            this.mwToolStrip1.Dock = System.Windows.Forms.DockStyle.None;
            this.mwToolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.btnDrawPath,
            this.btnGraph,
            this.btnDifficulty});
            this.mwToolStrip1.Location = new System.Drawing.Point(3, 0);
            this.mwToolStrip1.Map = this.mainMap;
            this.mwToolStrip1.Name = "mwToolStrip1";
            this.mwToolStrip1.Size = new System.Drawing.Size(380, 25);
            this.mwToolStrip1.TabIndex = 0;
            // 
            // btnDrawPath
            // 
            this.btnDrawPath.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.btnDrawPath.Image = ((System.Drawing.Image)(resources.GetObject("btnDrawPath.Image")));
            this.btnDrawPath.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.btnDrawPath.Name = "btnDrawPath";
            this.btnDrawPath.Size = new System.Drawing.Size(23, 22);
            this.btnDrawPath.Text = "toolStripButton1";
            this.btnDrawPath.ToolTipText = "Draw Ski Path";
            this.btnDrawPath.Click += new System.EventHandler(this.btnDrawPath_Click);
            // 
            // btnGraph
            // 
            this.btnGraph.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.btnGraph.Image = ((System.Drawing.Image)(resources.GetObject("btnGraph.Image")));
            this.btnGraph.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.btnGraph.Name = "btnGraph";
            this.btnGraph.Size = new System.Drawing.Size(23, 22);
            this.btnGraph.Text = "Show Graph";
            this.btnGraph.Click += new System.EventHandler(this.btnGraph_Click);
            // 
            // btnDifficulty
            // 
            this.btnDifficulty.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.btnDifficulty.Image = ((System.Drawing.Image)(resources.GetObject("btnDifficulty.Image")));
            this.btnDifficulty.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.btnDifficulty.Name = "btnDifficulty";
            this.btnDifficulty.Size = new System.Drawing.Size(23, 22);
            this.btnDifficulty.Text = "Ski Path Difficulty";
            // 
            // applicationManager1
            // 
            this.applicationManager1.DataManager.DataProviderDirectories = ((System.Collections.Generic.List<string>)(resources.GetObject("applicationManager1.DataManager.DataProviderDirectories")));
            this.applicationManager1.DataManager.LoadInRam = true;
            this.applicationManager1.DataManager.ProgressHandler = null;
            this.applicationManager1.Directories = ((System.Collections.Generic.List<string>)(resources.GetObject("applicationManager1.Directories")));
            this.applicationManager1.LayoutControl = null;
            this.applicationManager1.Legend = this.legend1;
            this.applicationManager1.MainMenu = this.menuStrip1;
            this.applicationManager1.MainToolStrip = this.menuStrip1;
            this.applicationManager1.Map = this.mainMap;
            this.applicationManager1.ProgressHandler = null;
            this.applicationManager1.ToolManager = null;
            this.applicationManager1.ToolStripContainer = this.toolStripContainer1;
            // 
            // MainForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(921, 577);
            this.Controls.Add(this.toolStripContainer1);
            this.Controls.Add(this.menuStrip1);
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MainMenuStrip = this.menuStrip1;
            this.Name = "MainForm";
            this.Text = "SkiPathFinder";
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            this.toolStripContainer1.BottomToolStripPanel.ResumeLayout(false);
            this.toolStripContainer1.BottomToolStripPanel.PerformLayout();
            this.toolStripContainer1.ContentPanel.ResumeLayout(false);
            this.toolStripContainer1.TopToolStripPanel.ResumeLayout(false);
            this.toolStripContainer1.TopToolStripPanel.PerformLayout();
            this.toolStripContainer1.ResumeLayout(false);
            this.toolStripContainer1.PerformLayout();
            this.statusStrip1.ResumeLayout(false);
            this.statusStrip1.PerformLayout();
            this.splitContainer1.Panel1.ResumeLayout(false);
            this.splitContainer1.Panel2.ResumeLayout(false);
            this.splitContainer1.ResumeLayout(false);
            this.mwToolStrip1.ResumeLayout(false);
            this.mwToolStrip1.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #endregion

        private void showGraphToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShowGraph();
        }

        private void btnGraph_Click(object sender, EventArgs e)
        {
            ShowGraph();
        }

        private void showPathDifficultyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PathDiffcuilty frmDiffcuilty = new PathDiffcuilty();
            frmDiffcuilty.Show();
        }

        
    }
}
